package algorithm.leetcode.q58;

/**
 * 最后一个单词
 * @author lsw
 * 2020-9-4 23:50:36
 */
public class LengthOfLastWord {
    public int lengthOfLastWord(String s) {

        if ("".equals(s.trim())) {
            return 0;
        }
//        String[] s1 = s.split(" ");
        return s.split(" ")[s.split(" ").length-1].length();

    }

    public static void main(String[] args) {
        LengthOfLastWord q58 = new LengthOfLastWord();
        int i = q58.lengthOfLastWord("Hell word");
        System.out.println(i);
    }
}
